﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;

namespace CPPEI.Coolzon.DesignServer.Domain
{
    public class DSDBContext : DbContext
    {
        static DSDBContext()
        {
            Database.SetInitializer<DSDBContext>(null);
        }

        public DSDBContext()
            : base("Name=DSDB")
        {
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Entities.Solution>().ToTable("DTSolution");
            modelBuilder.Entity<Entities.Solution>().HasKey(p => p.Id);

            modelBuilder.Entity<Entities.Workspace>().ToTable("DTWorkspace");
            modelBuilder.Entity<Entities.Workspace>().HasKey(p => p.Id);

            modelBuilder.Entity<Entities.Item>().ToTable("DTItem");
            modelBuilder.Entity<Entities.Item>().HasKey(p => p.Id);

            modelBuilder.Entity<Entities.ItemHistory>().ToTable("DTItemHistory");
            modelBuilder.Entity<Entities.ItemHistory>().HasKey(p => p.Id);

            modelBuilder.Entity<Entities.DataSource>().ToTable("DTDataSource");
            modelBuilder.Entity<Entities.DataSource>().HasKey(p => p.Id);

            modelBuilder.Entity<Entities.EntDataSet>().ToTable("DTDataSet");
            modelBuilder.Entity<Entities.EntDataSet>().HasKey(p => p.Id);

            modelBuilder.Entity<Entities.DataParameter>().ToTable("DTDataParameter");
            modelBuilder.Entity<Entities.DataParameter>().HasKey(p => p.Id);

            modelBuilder.Entity<Entities.EntPubDataSource>().ToTable("DTPubDataSource");
            modelBuilder.Entity<Entities.EntPubDataSource>().HasKey(p => p.Id);
                
            modelBuilder.Entity<Entities.EntPubDataSet>().ToTable("DTPubDataSet");
            modelBuilder.Entity<Entities.EntPubDataSet>().HasKey(p => p.Id);

            modelBuilder.Entity<Entities.EntPubDataParameter>().ToTable("DTPubDataParameter");
            modelBuilder.Entity<Entities.EntPubDataParameter>().HasKey(p => p.Id);
        }
    }
}